
//% color="#88AF75" iconWidth=50 iconHeight=40
namespace oitools{
    //% block="getline" blockType="command"
    export function getLine(parameter: any, block: any) {
        Generator.addCode(`s = input()`);
    }

    //% block="No.[ORDER] data convert to [TTYPE]" blockType="reporter"
    //% ORDER.shadow="number" ORDER.defl="0"
    //% TTYPE.shadow="dropdown" TTYPE.options="TTYPE" TTYPE.defl="TTYPE.int"
    export function sepInput(parameter: any, block: any) {
        let order = parameter.ORDER.code;
        let ttype = parameter.TTYPE.code;

        Generator.addCode([`${ttype}(s.split(" ")[${order}])`, Generator.ORDER_UNARY_POSTFIX]);
    }    

    //% block="getline's content" blockType="reporter"
    export function getLineContent(parameter: any, block: any) {
        Generator.addCode(`s`);
    }

    //% block="print [CONTENT] end up with [END]" blockType="command"
    //% CONTENT.shadow="string" CONTENT.defl=""
    //% END.shadow="dropdownRound" END.options="END" END.defl="END.linefeed"
    export function printWithEndUp(parameter: any, block: any) {
        let content = parameter.CONTENT.code;
        let end = parameter.END.code;

        Generator.addCode(`print(${content}, end=${end})`);
    }

    //% block="create [LENGTH] length [NUMTYPE] array set [VALUE]" blockType="reporter"
    //% LENGTH.shadow="number" LENGTH.defl="100"
    //% NUMTYPE.shadow="dropdown" NUMTYPE.options="NUMTYPE" NUMTYPE.defl="NUMTYPE.int"
    //% VALUE.shadow="number" VALUE.defl="0"
    export function createAndInitArray(parameter: any, block: any) {
        let length = parameter.LENGTH.code;
        let numtype = parameter.NUMTYPE.code;
        let value = parameter.VALUE.code;

        Generator.addCode([`[${numtype}(${value}) for i in range(${length})]`, Generator.ORDER_UNARY_POSTFIX])
    }


    function replaceQuotationMarks(str:string){
            str=str.replace(/"/g, ""); //去除所有引号
            return str
    }


    
}
